home *** CD-ROM | disk | FTP | other *** search
/ Postcardigtal: Baalbeck / postcardigtal: Baalbeck.iso / pc / efestival.swf / scripts / FUIComponentSymbol.as < prev   
Text File  |  2003-07-04  |  9KB  |  325 lines

  1. function FUIComponentClass()
  2. {
  3.    this.init();
  4. }
  5. FUIComponentClass.prototype = new MovieClip();
  6. FUIComponentClass.prototype.init = function()
  7. {
  8.    this.enable = true;
  9.    this.focused = false;
  10.    this.useHandCursor = false;
  11.    this._accImpl = new Object();
  12.    this._accImpl.stub = true;
  13.    this.styleTable = new Array();
  14.    if(_global.globalStyleFormat == undefined)
  15.    {
  16.       _global.globalStyleFormat = new FStyleFormat();
  17.       globalStyleFormat.isGlobal = true;
  18.       _global._focusControl = new Object();
  19.       _global._focusControl.onSetFocus = function(oldFocus, newFocus)
  20.       {
  21.          oldFocus.myOnKillFocus();
  22.          newFocus.myOnSetFocus();
  23.       };
  24.       Selection.addListener(_global._focusControl);
  25.    }
  26.    if(this._name != undefined)
  27.    {
  28.       this._focusrect = false;
  29.       this.tabEnabled = true;
  30.       this.focusEnabled = true;
  31.       this.tabChildren = false;
  32.       this.tabFocused = true;
  33.       if(this.hostStyle == undefined)
  34.       {
  35.          globalStyleFormat.addListener(this);
  36.       }
  37.       else
  38.       {
  39.          this.styleTable = this.hostStyle;
  40.       }
  41.       this.deadPreview._visible = false;
  42.       this.deadPreview._width = this.deadPreview._height = 1;
  43.       this.methodTable = new Object();
  44.       this.keyListener = new Object();
  45.       this.keyListener.controller = this;
  46.       this.keyListener.onKeyDown = function()
  47.       {
  48.          this.controller.myOnKeyDown();
  49.       };
  50.       this.keyListener.onKeyUp = function()
  51.       {
  52.          this.controller.myOnKeyUp();
  53.       };
  54.       for(var i in this.styleFormat_prm)
  55.       {
  56.          this.setStyleProperty(i,this.styleFormat_prm[i]);
  57.       }
  58.    }
  59. };
  60. FUIComponentClass.prototype.setEnabled = function(enabledFlag)
  61. {
  62.    this.enable = arguments.length <= 0 ? true : enabledFlag;
  63.    this.tabEnabled = this.focusEnabled = enabledFlag;
  64.    if(!this.enable && this.focused)
  65.    {
  66.       Selection.setFocus(undefined);
  67.    }
  68. };
  69. FUIComponentClass.prototype.getEnabled = function()
  70. {
  71.    return this.enable;
  72. };
  73. FUIComponentClass.prototype.setSize = function(w, h)
  74. {
  75.    this.width = w;
  76.    this.height = h;
  77.    this.focusRect.removeMovieClip();
  78. };
  79. FUIComponentClass.prototype.setChangeHandler = function(chng, obj)
  80. {
  81.    this.handlerObj = obj != undefined ? obj : this._parent;
  82.    this.changeHandler = chng;
  83. };
  84. FUIComponentClass.prototype.invalidate = function(methodName)
  85. {
  86.    this.methodTable[methodName] = true;
  87.    this.onEnterFrame = this.cleanUI;
  88. };
  89. FUIComponentClass.prototype.cleanUI = function()
  90. {
  91.    if(this.methodTable.setSize)
  92.    {
  93.       this.setSize(this.width,this.height);
  94.    }
  95.    else
  96.    {
  97.       this.cleanUINotSize();
  98.    }
  99.    this.methodTable = new Object();
  100.    delete this.onEnterFrame;
  101. };
  102. FUIComponentClass.prototype.cleanUINotSize = function()
  103. {
  104.    for(var funct in this.methodTable)
  105.    {
  106.       this[funct]();
  107.    }
  108. };
  109. FUIComponentClass.prototype.drawRect = function(x, y, w, h)
  110. {
  111.    var inner = this.styleTable.focusRectInner.value;
  112.    var outer = this.styleTable.focusRectOuter.value;
  113.    if(inner == undefined)
  114.    {
  115.       inner = 16777215;
  116.    }
  117.    if(outer == undefined)
  118.    {
  119.       outer = 0;
  120.    }
  121.    this.createEmptyMovieClip("focusRect",1000);
  122.    this.focusRect.controller = this;
  123.    this.focusRect.lineStyle(1,outer);
  124.    this.focusRect.moveTo(x,y);
  125.    this.focusRect.lineTo(x + w,y);
  126.    this.focusRect.lineTo(x + w,y + h);
  127.    this.focusRect.lineTo(x,y + h);
  128.    this.focusRect.lineTo(x,y);
  129.    this.focusRect.lineStyle(1,inner);
  130.    this.focusRect.moveTo(x + 1,y + 1);
  131.    this.focusRect.lineTo(x + w - 1,y + 1);
  132.    this.focusRect.lineTo(x + w - 1,y + h - 1);
  133.    this.focusRect.lineTo(x + 1,y + h - 1);
  134.    this.focusRect.lineTo(x + 1,y + 1);
  135. };
  136. FUIComponentClass.prototype.pressFocus = function()
  137. {
  138.    this.tabFocused = false;
  139.    this.focusRect.removeMovieClip();
  140.    Selection.setFocus(this);
  141. };
  142. FUIComponentClass.prototype.drawFocusRect = function()
  143. {
  144.    this.drawRect(-2,-2,this.width + 4,this.height + 4);
  145. };
  146. FUIComponentClass.prototype.myOnSetFocus = function()
  147. {
  148.    this.focused = true;
  149.    Key.addListener(this.keyListener);
  150.    if(this.tabFocused)
  151.    {
  152.       this.drawFocusRect();
  153.    }
  154. };
  155. FUIComponentClass.prototype.myOnKillFocus = function()
  156. {
  157.    this.tabFocused = true;
  158.    this.focused = false;
  159.    this.focusRect.removeMovieClip();
  160.    Key.removeListener(this.keyListener);
  161. };
  162. FUIComponentClass.prototype.executeCallBack = function()
  163. {
  164.    this.handlerObj[this.changeHandler](this);
  165. };
  166. FUIComponentClass.prototype.updateStyleProperty = function(styleFormat, propName)
  167. {
  168.    this.setStyleProperty(propName,styleFormat[propName],styleFormat.isGlobal);
  169. };
  170. FUIComponentClass.prototype.setStyleProperty = function(propName, value, isGlobal)
  171. {
  172.    if(value == "")
  173.    {
  174.       return undefined;
  175.    }
  176.    var tmpValue = parseInt(value);
  177.    if(!isNaN(tmpValue))
  178.    {
  179.       value = tmpValue;
  180.    }
  181.    var global = arguments.length <= 2 ? false : isGlobal;
  182.    if(this.styleTable[propName] == undefined)
  183.    {
  184.       this.styleTable[propName] = new Object();
  185.       this.styleTable[propName].useGlobal = true;
  186.    }
  187.    if(this.styleTable[propName].useGlobal || !global)
  188.    {
  189.       this.styleTable[propName].value = value;
  190.       if(!this.setCustomStyleProperty(propName,value))
  191.       {
  192.          if(propName == "embedFonts")
  193.          {
  194.             this.invalidate("setSize");
  195.          }
  196.          else if(propName.subString(0,4) == "text")
  197.          {
  198.             if(this.textStyle == undefined)
  199.             {
  200.                this.textStyle = new TextFormat();
  201.             }
  202.             var textProp = propName.subString(4,propName.length);
  203.             this.textStyle[textProp] = value;
  204.             this.invalidate("setSize");
  205.          }
  206.          else
  207.          {
  208.             for(var j in this.styleTable[propName].coloredMCs)
  209.             {
  210.                var myColor = new Color(this.styleTable[propName].coloredMCs[j]);
  211.                if(this.styleTable[propName].value == undefined)
  212.                {
  213.                   var myTObj = {ra:"100",rb:"0",ga:"100",gb:"0",ba:"100",bb:"0",aa:"100",ab:"0"};
  214.                   myColor.setTransform(myTObj);
  215.                }
  216.                else
  217.                {
  218.                   myColor.setRGB(value);
  219.                }
  220.             }
  221.          }
  222.       }
  223.       this.styleTable[propName].useGlobal = global;
  224.    }
  225. };
  226. FUIComponentClass.prototype.registerSkinElement = function(skinMCRef, propName)
  227. {
  228.    if(this.styleTable[propName] == undefined)
  229.    {
  230.       this.styleTable[propName] = new Object();
  231.       this.styleTable[propName].useGlobal = true;
  232.    }
  233.    if(this.styleTable[propName].coloredMCs == undefined)
  234.    {
  235.       this.styleTable[propName].coloredMCs = new Object();
  236.    }
  237.    this.styleTable[propName].coloredMCs[skinMCRef] = skinMCRef;
  238.    if(this.styleTable[propName].value != undefined)
  239.    {
  240.       var myColor = new Color(skinMCRef);
  241.       myColor.setRGB(this.styleTable[propName].value);
  242.    }
  243. };
  244. _global.FStyleFormat = function()
  245. {
  246.    this.nonStyles = {listeners:true,isGlobal:true,isAStyle:true,addListener:true,removeListener:true,nonStyles:true,applyChanges:true};
  247.    this.listeners = new Object();
  248.    this.isGlobal = false;
  249.    if(arguments.length > 0)
  250.    {
  251.       for(var i in arguments[0])
  252.       {
  253.          this[i] = arguments[0][i];
  254.       }
  255.    }
  256. };
  257. _global.FStyleFormat.prototype = new Object();
  258. FStyleFormat.prototype.addListener = function()
  259. {
  260.    var arg = 0;
  261.    while(arg < arguments.length)
  262.    {
  263.       var mcRef = arguments[arg];
  264.       this.listeners[arguments[arg]] = mcRef;
  265.       for(var i in this)
  266.       {
  267.          if(this.isAStyle(i))
  268.          {
  269.             mcRef.updateStyleProperty(this,i.toString());
  270.          }
  271.       }
  272.       arg++;
  273.    }
  274. };
  275. FStyleFormat.prototype.removeListener = function(component)
  276. {
  277.    this.listeners[component] = undefined;
  278.    for(var prop in this)
  279.    {
  280.       if(this.isAStyle(prop))
  281.       {
  282.          if(component.styleTable[prop].useGlobal == this.isGlobal)
  283.          {
  284.             component.styleTable[prop].useGlobal = true;
  285.             var value = !this.isGlobal ? globalStyleFormat[prop] : undefined;
  286.             component.setStyleProperty(prop,value,true);
  287.          }
  288.       }
  289.    }
  290. };
  291. FStyleFormat.prototype.applyChanges = function()
  292. {
  293.    var count = 0;
  294.    for(var i in this.listeners)
  295.    {
  296.       var component = this.listeners[i];
  297.       if(arguments.length > 0)
  298.       {
  299.          var j = 0;
  300.          while(j < arguments.length)
  301.          {
  302.             if(this.isAStyle(arguments[j]))
  303.             {
  304.                component.updateStyleProperty(this,arguments[j]);
  305.             }
  306.             j++;
  307.          }
  308.       }
  309.       else
  310.       {
  311.          for(var j in this)
  312.          {
  313.             if(this.isAStyle(j))
  314.             {
  315.                component.updateStyleProperty(this,j.toString());
  316.             }
  317.          }
  318.       }
  319.    }
  320. };
  321. FStyleFormat.prototype.isAStyle = function(name)
  322. {
  323.    return !this.nonStyles[name] ? true : false;
  324. };
  325.